<?php
/**
 * Created by PhpStorm.
 * User: beich
 * Date: 2019/1/29
 * Time: 13:56
 */
include_once 'c.php';
$id = $_GET['id'];
$DocData = Response::getData("select id,title,tag from `doc_document` where id = {$id}", $con);
if ($DocData->id == '') {
    header("Location: /404.html");
}
$DocDatas = Response::getDatas("select id,name,contentID from `doc_tree` where docID ={$id} order by listsort", $con);
?>
<!doctype html>
<html class="no-js" lang="zxx">


<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Karigor - Portfolio Bootstrap4 Template</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Favicon -->
    <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon" href="img/icon.png">

    <!-- Google font (font-family: 'Dosis', sans-serif;) -->
    <link href="https://fonts.googleapis.com/css?family=Dosis:300,400,500,600,700" rel="stylesheet">

    <!-- Plugins -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/plugins.css">

    <!-- Style Css -->
    <link rel="stylesheet" href="css/style.css">

    <!-- Custom Styles -->
    <link rel="stylesheet" href="css/custom.css">
</head>

<body>

<!-- Wrapper -->
<div id="wrapper" class="wrapper">

    <!-- Header -->
    <header class="header sticky-header">
        <div class="container">
            <div class="header-inner d-none d-lg-flex">
                <div class="header-logo">
                    <a href="index.html">
                        <img src="img/logo/logo-dark.png" alt="logo">
                    </a>
                </div>
                <div class="header-navigation">
                    <button class="header-navigation-trigger">
                        <span></span>
                        <span></span>
                        <span></span>
                    </button>
                    <nav class="main-navigation">
                        <?= Response::ulLis($con) ?>
                    </nav>
                </div>
            </div>
            <div class="mobile-menu-wrapper d-block d-lg-none">
                <div class="mobile-menu clearfix">
                    <a href="index.html" class="mobile-logo">
                        <img src="img/logo/logo-dark.png" alt="mobile logo">
                    </a>
                </div>
            </div>
        </div>
    </header>
    <!--// Header -->

    <!-- Breadcrumb Area -->
    <div class="breadcrumb-area bg-grey">
        <div class="container">
            <div class="cr-breadcrumb">
                <h2><?= $DocData->title ?></h2>
                <ul>
                    <li><a href="index.html">Home</a></li>
                    <li><a href="doc.html">DOCUMENT</a></li>
                    <li><?= $DocData->id ?></li>
                </ul>
            </div>
        </div>
    </div>
    <!--// Breadcrumb Area -->

    <!-- Page Conttent -->
    <main class="page-content">

        <!-- Blog Area -->
        <div class="cr-section blog-area section-padding-lg">
            <div class="container">
                <div class="row">

                    <div class="col-xl-9 col-lg-8 col-12 order-1 order-lg-2">

                        <div class="blog-details">

                            <article class="blog-item ">
                                <!--<div class="blog-item-header">-->
                                <!--<img src="img/blog/blog-details/blog-image-1.jpg" alt="blog thumb">-->
                                <!--</div>-->

                                <div class="blog-item-body">
                                    <div class="tab-content" id="v-pills-tabContent">

                                        <?php
                                        $j = 1;
                                        foreach ($DocDatas as $Doc) {
                                            $cID = $Doc->contentID;
                                            $Content = Response::getData("select content from `doc_content` where id = '{$cID}'", $con)->content;
                                            if ($j == 1) {
                                                echo '<div class="tab-pane fade show active" id="v-pills-' . $Doc->id . '" role="tabpanel"
                                             aria-labelledby="v-pills-messages-tab">
                                            ' . $Content . '
                                        </div>';
                                            } else {
                                                echo '<div class="tab-pane fade " id="v-pills-' . $Doc->id . '" role="tabpanel"
                                             aria-labelledby="v-pills-messages-tab">
                                            ' . $Content . '
                                        </div>';
                                            }
                                            $j++;
                                        }
                                        if ($j == 1) {
                                            ?>
                                            <img src="img/404.png" alt="">
                                            <?php
                                        }
                                        ?>
                                    </div>
                                </div>
                                <div class="blog-item-footer">
                                    <ul class="blog-item-meta">
                                        <li><i class="fa fa-user-o"></i>By <a href="blog.html">Admin</a></li>
                                        <li><i class="fa fa-calendar-o"></i> 30 Nov 2018</li>
                                        <li><i class="fa fa-comments-o"></i><a href="#">3 Comments</a></li>
                                    </ul>
                                </div>
                            </article>

                            <div class="blog-details-bottom">
                                <div class="blog-details-tags">
                                    <h6>Tags: </h6>
                                    <ul>
                                        <li><?= $DocData->tag ?></li>
                                    </ul>
                                </div>
                                <div class="blog-details-share">
                                    <h6>Share: </h6>
                                    <ul>
                                        <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                                        <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                                        <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
                                        <li><a href="#"><i class="fa fa-linkedin"></i></a></li>
                                    </ul>
                                </div>
                            </div>


                        </div>
                    </div>
                    <div class="col-xl-3 col-lg-4 col-12 order-2 order-lg-1 sticky-sidebar-active">
                        <div class="widgets">

                            <!-- Single Widget -->
                            <section class="single-widget widget-search">
                                <h5 class="widget-title">SEARCH</h5>
                                <form action="#">
                                    <input type="text" placeholder="Search...">
                                    <button type="submit"><i class="fa fa-search"></i></button>
                                </form>
                            </section>
                            <!--// Single Widget -->

                            <!-- Single Widget -->
                            <section class="single-widget widget-categories">
                                <h5 class="widget-title">CATEGORIES</h5>
                                <div class="nav flex-column nav-pills" id="v-pills-tab1" role="tablist"
                                     aria-orientation="vertical">
                                    <?php
                                    $i = 1;
                                    foreach ($DocDatas as $Doc) {
                                        if ($i == 1) {
                                            echo '<a class="nav-link active" id="v-pills-home-tab" data-toggle="pill"
                                       href="#v-pills-' . $Doc->id . '" role="tab" aria-controls="v-pills-home"
                                       aria-selected="true">' . $Doc->name . '</a>';
                                        } else {
                                            echo '<a class="nav-link " id="v-pills-home-tab" data-toggle="pill"
                                       href="#v-pills-' . $Doc->id . '" role="tab" aria-controls="v-pills-home"
                                       aria-selected="true">' . $Doc->name . '</a>';
                                        }
                                        $i++;
                                    }
                                    if($i==1){
                                        ?>
                                    <a class="nav-link" id="v-pills-home-tab" data-toggle="pill"
                                       href="#" role="tab" aria-controls="v-pills-home"
                                       aria-selected="true">无</a>
                                        <?php
                                    }
                                    ?>
                                </div>
                            </section>


                            <!-- Single Widget -->
                            <section class="single-widget widget-tags">
                                <h5 class="widget-title">TAGS</h5>
                                <ul>
                                    <?php
                                    if ($DocData->tag == '') {
                                        echo '<li><a href="javascript:void(0)">无</a></li>';
                                    } else {
                                        foreach (explode(',', $DocData->tag) as $tag) {
                                            echo '<li><a href="javascript:void(0)">' . $tag . '</a></li>';
                                        }
                                    }
                                    ?>

                                </ul>
                            </section>
                            <!--// Single Widget -->

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--// Blog Area -->

    </main>
    <!--// Page Conttent -->
    <?= Response::$footer ?>

</div>
<!--// Wrapper -->

<!-- Js Files -->
<script src="js/vendor/modernizr-3.6.0.min.js"></script>
<script src="js/vendor/jquery-3.3.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>

</body>


</html>
